#include "dkglSkyBox.h"
#include "dkglTexture.h"

#include <sstream>

namespace DKGL
{
/*
    class SkyBobImpl
    {
    public:

        void render()
        {
            
        }

    glEnd();
        }

    private:


    };
*/
    SkyBox::SkyBox()
        :Box("SkyBox", 30, 30, 30)
    {
        _construct();
    }

    SkyBox::~SkyBox()
    {
    }

    void SkyBox::_construct()
    {
        String name("skybox.png");
        //std::wstring name(L"5.jpg");

        if (!texture.load(name))
        {
            //std::wstringstream wss;
            //wss << "Can't load texture:" << name;

            throw std::runtime_error("");
        }
    }


    void SkyBox::drawEntity()
    {
        glPushAttrib(GL_ENABLE_BIT);
        glEnable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        glDisable(GL_BLEND);
        glFrontFace(GL_CW);

        glColor3f(1.0f, 1.0f, 1.0f);

        texture.bind();

	    glBegin(GL_QUADS);

        for (int i=0;i<24;i++)
        {
            /*glTexCoord2f(texCoordBuf[tindexBuf[i]].x,
                texCoordBuf[tindexBuf[i]].y);

            glNormal3f(normalBuf[nindexBuf[i]].x,
                normalBuf[nindexBuf[i]].y,
                normalBuf[nindexBuf[i]].z); 

            glVertex3f(mVertBuf[vindexBuf[i]].x,
                mVertBuf[vindexBuf[i]].y,
                mVertBuf[vindexBuf[i]].z); */
        }
        glEnd();

        glFrontFace(GL_CCW);
        glPopAttrib();
    }


}//namespace
